
export class CommunicationService {

	getServerTime(callback: Function) {
		// Start hub, call .NET method of this hub and call callback on its result.
        $.connection.hub.start().then(() => 
			$.connection.devicesHub.server.getServerTime().then(t => callback(t)));		
	}
	
	init() {
		$.connection.hub.start().then(() => $.connection.devicesHub.server.init());			
	}
	
	subscribeToBrowserFunction(hubName: string, funcName: string, callback: Function) {
		var connection = $.hubConnection('');
        connection.createHubProxy(hubName).on(funcName, data => callback(data));
		connection.start();
	}
}
